var api = require('../../utils/api.js');
var app = getApp();


Page({

    /**
     * 页面的初始数据
     */
    data: {
        lists:[],
        id:''
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
        var that=this;

        this.setData({
            id:options.id
        })
        this.getalist();
    },

    getalist(){
        var that=this;
        var id=this.data.id;
        api.post({
            url: 'huodong/getalllistby',
            data: {id:id},
            success: data => {
                console.log(data);
                that.setData({
                    lists:data.data
                })
            }
        });
    },

    seeinfo(ret){
        console.log(ret);
        var id=ret.currentTarget.dataset.id;
        wx.navigateTo({
          url: '/pages/news/info?id='+id
        })

    },

    //阅读
    seeonebyid(ret){

        var id=ret.currentTarget.dataset.id;

        var that=this;
        api.post({
            url: 'huodong/seeonebyid',
            data: {id:id},
            success: data => {
                console.log(data);
                that.getalist();
            }
        });
    },

     //阅读
     seeallbyid(ret){

        var id=this.data.id;

        var that=this;
        api.post({
            url: 'huodong/seeallbyid',
            data: {id:id},
            success: data => {
                console.log(data);
                that.getalist();
            }
        });
    }

})